#include <stdio.h>
#include <stdlib.h>
void printp(int* p, int num)
{
	for (int i = 0;i < num;i++)
	{
		printf("%d ", p[i]);
	}
}
int getMax(int *p, int length)
{
	int max = -1;
	for (int i = 0;i < length;i++)
	{
		if (max < p[i])
		{
			max = p[i];
		}
	}
	return max;
}
void sort(int* p, int length)
{
	int jishu[1000];
	int chongfu[1000];
	for (int i = 0;i < 1000;i++)
	{
		jishu[i] = 0;
		chongfu[i] = 1;
	}
	for (int i = 0; i < length; i++)
	{
		if (jishu[p[i]] == 0)
		{
			jishu[p[i]] = p[i];
		}
		else {
			chongfu[p[i]]++;
		}
	}
	int count = 0;
	//printp(jishu, 1000);
	//printp(chongfu, 1000);
	//printf("%d", length);
	for (int i = 0; i < length; i++)
	{
		//printf("%d ",jishu[i]);
		if (jishu[i] != 0)
		{
			for (int j = 0;j < chongfu[i];j++)
			{
				//printf("%d ", jishu[i]==0);
				p[count] = jishu[i];
				count++;
			}
		}
	}
}

int find(int* p, int length, int num)
{
	for (int i = 0; i < length; i++)
	{
		if (p[i] == num)
		{
			return i;
		}
	}

	return -1;
}
int main()
{
	int p[1000];
	srand(1);
	//rand(100);
	for (int i = 0;i < 1000;i++)
	{
		p[i]=rand() % 1000;
	}
	sort(p, 1000);
	printp(p, 1000);
	return 0;
}